package com.fronald.getbot.misc;

import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileNameExtensionFilter;

/**
 *
 * @author franklin
 */
public class SystemUtil {

    public static String getDiretorioUsuario() {
        return System.getProperty("user.home");
    }

    public static JFileChooser exibeDialogoArquivos() {
        return exibeDialogoArquivos(null);
    }

    public static JFileChooser exibeDialogoArquivos(FileNameExtensionFilter fn) {
        JFileChooser jfc = new JFileChooser();
        if (fn == null) {
            fn = new FileNameExtensionFilter("XL Spreadsheet (Planilha do Excel)", "xls");
        }
        jfc.setFileFilter(fn);
        jfc.setAcceptAllFileFilterUsed(false);
        jfc.setCurrentDirectory(new File(SystemUtil.getDiretorioUsuario()));
        jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
        jfc.setMultiSelectionEnabled(false);
        return jfc;
    }
}
